import {
    reqspecslist,
    reqspecsinfo
} from "../../request/api.js"
const state = {
    info: {
        isshow: false,
        isadd: true
    },
    reqpage: {
        size: 5,
        page: 1
    },
    specslist: [],
    specsinfo: [],
}
const getters = {
    info(state) {
        return state.info
    },
    specslist(state) {
        return state.specslist
    },
    specsinfo(state) {
        return state.specsinfo
    },
}
const mutations = {
    changeinfo(state, data) {
        state.info = data
    },
    specslist(state, data) {
        state.specslist = data
    },
    specsinfo(state, data) {
        state.specsinfo = data
    },

}
const actions = {
    specslist(context) {
        console.log(1);
        reqspecslist(context.state.reqpage).then(res => {
            context.commit("specslist", res.data.list)
        })
    },
    specsinfo(context, data) {
        reqspecsinfo(data).then(res => {
            res.data.list.id = data.id
            context.commit("specsinfo", res.data.list)
        })
    },
}
export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}